package ch3;

import javax.xml.bind.SchemaOutputResolver;
import java.util.Scanner;

public class CalculatorTest {//4:计算器用颜色，品牌，价格等属性，有计算加减乘除以及算一个数立方的方法，
    // 用oo的思想模拟（提示，计算立方只要一个参数）。
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Calculator jsq = new Calculator();
        jsq.brand = "晨光文具";
        jsq.colour = "黑色";
        jsq.price = 29.98f;
        System.out.println("这个计算器的品牌：" + jsq.brand + ",颜色是：" + jsq.colour + ",价格是：" + jsq.price + "元");
        while (true) {
            double b;
            double c;
            System.out.println("1、加；2、减；3、乘；4、除；5、立方；0、退出");
            int a = input.nextInt();
            System.out.println("请输入第一个数：");
            b = input.nextDouble();
            System.out.println("请输入第二个数：");
            c = input.nextDouble();
            switch (a) {
                case 0:
                    System.out.println("退出");
                    return;
                case 1:
                    System.out.println("加法：" + jsq.add(b, c));
                    break;
                case 2:
                    System.out.println("减法：" + jsq.subtract(b, c));
                    break;
                case 3:
                    System.out.println("乘法：" + jsq.multiply(b, c));
                    break;
                case 4:
                    System.out.println("除法：" + jsq.divide(b, c));
                    break;
                case 5:
                    System.out.println("请输入一个数：");
                    double d = input.nextDouble();
                    System.out.println("立方：" + jsq.cube(d));
                    break;

            }
        }
    }
}
